<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,aItemress=no">
    <title>商城-登录注册</title>
    <link rel="stylesheet" type="text/css" href="../../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/app.css" />
    <style type="text/css">
        body {
            background: none;
        }

        .mxgbox {
            position: fixed;
            top: 5rem;
            bottom: 5rem;
            left: 2rem;
            right: 2rem;
            background: #fff;
            border-radius: .5rem;
            padding: .75rem;
        }

        .mxgbox-footer .item {
            text-align: center;
            padding-top: .5rem;
            font-size: .9rem;
            font-weight: 600;
        }

        .mxgbox-footer .item.right {
            color: #009688;
        }

        .mxgbox-body {
            overflow-y: scroll;
            -webkit-overflow-scrolling: touch;
        }
    </style>
</head>

<body>
    <div class="" id="app">

        <div class="mxgbox flex-box-y">
            <div class="mxgbox-body col-xs-y" v-html="details.content"></div>
            <div class="mxgbox-footer flex-box-x">
                <div class="item left col-xs-x" @click="closePopup">暂不使用</div>
                <div class="item right col-xs-x" @click="agreePopup">同意</div>
            </div>
        </div>

    </div>
</body>
<script type="text/javascript" src="../../../script/api.js"></script>
<script type="text/javascript" src="../../../script/vue.js"></script>
<script type="text/javascript" src="../../../script/common.js"></script>
<script>
    apiready = function() {
        var vm = new Vue({
            el: "#app",
            data: {
                details: {}
            },
            methods: {
                openMsgbox: function() {
                    api.openFrame({
                        name: 'yinsi_msgbox_next',
                        url: 'widget://html/login/components/msgbox_next.html',
                        bounces: false,
                        vScrollBarEnabled: false,
                        bgColor: 'rgba(0,0,0,0.5)',
                        rect: {
                            x: 0,
                            y: 0,
                            w: 'auto',
                            h: 'auto'
                        },
                        pageParam: {}
                    })
                },
                getDetails: function() {
                    get_data('api/page/details', {
                        title: '用户协议'
                    }, function(ret) {
                        console.log(JSON.stringify(ret))
                        if (ret.status) {
                            vm.details = ret.data
                        }
                    })
                },
                agreePopup: function() {
                    // api.setPrefs({
                    //     key: 'agree',
                    //     value: true
                    // });
                    vm.openMsgbox()
                    api.closeFrame({
                        name: 'yinsi_msgbox'
                    });
                },
                closePopup: function() {

                    api.confirm({
                        title: '是否同意用户协议?',
                        msg: '',
                        buttons: ['同意并继续', '退出应用']
                    }, function(ret, err) {


                        var index = ret.buttonIndex;
                        if (index == 1) {
                          vm.openMsgbox()
                            // api.setPrefs({
                            //     key: 'agree',
                            //     value: true
                            // });

                        }

                        if (index == 2) {
                            api.closeWidget({

                                id: 'A6025575931208', //这里改成自己的应用ID

                                retData: {
                                    name: 'closeWidget'
                                },

                                silent: true

                            });
                        }

                        api.closeFrame({
                            name: 'yinsi_msgbox'
                        });

                    });

                },
            },
            mounted() {
                this.getDetails();
            }
        })


    }
</script>

</html>
